package cn.wolfcode.luowowo.website.web.controller;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.domain.Hotel;
import cn.wolfcode.luowowo.article.domain.HotelTheme;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.article.service.IHotelService;
import cn.wolfcode.luowowo.article.service.IHotelThemeService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/hotel")
public class HotelController {

    @Reference
    private IDestinationService destinationService;

    @Reference
    private IHotelService hotelService;

    @Reference
    private IHotelThemeService hotelThemeService;

    @RequestMapping("")
    public String hotel(Model model){

        //目的地:国内
        List<Destination> dest = destinationService.listChinaDest();
        model.addAttribute("dest",dest);

        //目的地:海外
        List<Destination> overseas = destinationService.listOverseasDest();
        model.addAttribute("overseas",overseas);


        //主题住宿hotelTags
        List<HotelTheme> hotelTags = hotelThemeService.list();
        model.addAttribute("hotelTags",hotelTags);

        //特价酒店:hotelCity
        List<Hotel> hotelCity = hotelService.list();
        model.addAttribute("hotelCity",hotelCity);

        return "hotel/hotel";
    }

    @RequestMapping("/theme")
    public String theme(Model model,String themeName){

        //查询主题对应的目的地
        List<Destination> list = destinationService.listByThemeName(themeName);
        model.addAttribute("list",list);
        for (Destination destination : list) {
            System.out.println(destination);
        }

        //特价酒店
        hotelService.list();

        return "hotel/hotelTpl";
    }
}
























